package demo.DataStrucAndAlgo.demo;

import java.util.Scanner;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/10/22-10-22-16:27
 * @Description：demo.DataStrucAndAlgo.demo
 */
public class MeiTuanTest2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int A = sc.nextInt();
        int[] len = new int[n];
        int[] beauty = new int[n];
        for (int i = 0; i < n; i++) {
            len[i] = sc.nextInt();
        }
        for(int i = 0; i < n; i++){
            beauty[i] = sc.nextInt();
        }

        int max = 0;
        for (int i = 0; i < n; i++) {
            int j = i;
            int road = 0;
            int result = 0;
            while(road < A && j < n){
                result = result + beauty[j];
                road = road + len[j] ;
                j++;
            }
            if(max < result){
                max = result;
            }
        }
        System.out.println(max);
    }
}
